package tech.yangzhijie.basic.java05;

public class Tests {
    public static void main(String[] args) {
        /*int[] arr = new int[10];
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }*/
        /*int[] arr = {4,1,1,1};
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+"\t");
        }
        System.out.println();
        change(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+"\t");
        }*/
       /* String s = "abcd";
        StringBuffer s1 = new StringBuffer(s);
        System.out.println(s1.capacity()+"  "+s1.length());//20  4*/
        /*Vector<Integer> vector = new Vector<>();
        System.out.println(vector.capacity());//10
        for (int i = 0; i < 40; i++) {
            vector.addElement(i);
        }
        vector.addElement(40);
        System.out.println(vector.capacity());
        System.out.println(vector.elementAt(1));*/
        //moveToFront(new int[]{1,2,3,4,5,6,7,8,9});
        /*char[] a = {'1','2','3','4','5','6','7'};
        String s1 = new String(a,2,4);
        String s2 = "JavaWorld!";
        System.out.println(s1);//3456
        System.out.println(s2.indexOf("a"));//1
        System.out.println(s2.replace("t","r"));//JavaWorld!
        System.out.println(s2.substring(4,6));//Wo*/
        //test03(4);
        
    }

    private static void change(int[] arr){
        arr = new int[]{1,1,2,3,4};
    }

    private static void moveToFront(int a[]){
        int odd = 0;
        for(int k=0;k<a.length;k++){
            if(a[k]%2==1){
                int t = a[odd];
                a[odd] = a[k];
                a[k] = t;
                odd++;
            }
        }
        System.out.println(odd);

        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i]+"\t");
        }
    }

    private static void test03(int n){
        int[][] a = new int[n][n];
        int k = 1;
        for (int i = 0; i < n; i++) {
            if(i%2==0){
                for (int j = 0; j <= i; j++) {
                    a[i][j] = k++;
                }
                for (int j = i-1;j>=0;j--){
                    a[j][i] = k++;
                }
            }else {
                for (int j = 0; j <= i; j++) {
                    a[j][i] = k++;
                }
                for (int j = i-1;j>=0;j--){
                    a[i][j] = k++;
                }
            }
        }

        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < a[i].length; j++) {
                System.out.print(a[i][j]+"\t");

            }
        }
    }
}
